﻿using System;

namespace PropertyExpression.ControllableQuery.Test
{
    public partial class PartLinkQuery : IQuery<PartLinkInfo>
    {
        private readonly IInnerPartLinkSwitcher innerPartLinkSwitcher;
        public readonly IParams<PartLinkParams> PartLinkParams;

        public PartLinkQuery(
            IInnerPartLinkSwitcher innerPartLinkSwitcher, IParams<PartLinkParams> partLinkParams)
        {
            this.innerPartLinkSwitcher = innerPartLinkSwitcher;
            PartLinkParams = partLinkParams;
        }
    }

    public partial class PartLinkInfo
    {        
    }

    public partial class PartLinkParams
    {
    }

    public interface IInnerPartLinkSwitcher
    {
        void AddSubQuery(Action<bool> action);
    }

    public class WithoutInnerPartLinkSwitcher : IInnerPartLinkSwitcher
    {
        public void AddSubQuery(Action<bool> action)
        {
            //no-op
        }
    }

    public class WithInnerPartLinkSwitcher : IInnerPartLinkSwitcher
    {
        private readonly bool latestPublicationOnly;
        public readonly IParams<PartLinkParams> PartLinkParams;

        public WithInnerPartLinkSwitcher(bool latestPublicationOnly, IParams<PartLinkParams> partLinkParams)
        {
            this.latestPublicationOnly = latestPublicationOnly;
            PartLinkParams = partLinkParams;
        }

        public void AddSubQuery(Action<bool> action)
        {
            action(latestPublicationOnly);
        }
    }

    public partial class InnerPartLinkParams
    {
    }
}
